From 45656ba4263dfca9df240c7621091136c40fc96b Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 9 Jun 2023 01:04:27 +0200 Subject: [PATCH] testsuite: Make memorytexture tests random Instead of picking a few numbers in advance and running them through the test gauntlet every time, pick the random numbers at runtime. This both increases the test coverage in that it ultimately tests more combinations across many runs and it reduces the runtime of individual runs because every tun only runs the download tests twice (with 1px and the random size) instead of 5 times. And that speedup benefits the CI, where the asan runs would cause this test to timeout sometimes. --- testsuite/gdk/memorytexture.c | 45 +++++++++++++---------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/testsuite/gdk/memorytexture.c b/testsuite/gdk/memorytexture.c index 62329f61e7..138eb6844b 100644 --- a/testsuite/gdk/memorytexture.c +++ b/testsuite/gdk/memorytexture.c @@ -1188,30 +1188,22 @@ test_download_1x1 (gconstpointer data) } static void -test_download_4x4 (gconstpointer data) +test_download_random (gconstpointer data) { - test_download (data, 4, 4); -} + int width, height; -/* odd sizes, to trigger alignment issues */ -static void -test_download_17x7 (gconstpointer data) -{ - test_download (data, 17, 7); -} - -/* larger than what GSK puts into the icon cache */ -static void -test_download_192x192 (gconstpointer data) -{ - test_download (data, 192, 192); -} + /* Make sure the maximum is: + * - larger than what GSK puts into the icon cache + * - larger than the small max-texture-size we test against + */ + do + { + width = g_test_rand_int_range (1, 40) * g_test_rand_int_range (1, 40); + height = g_test_rand_int_range (1, 40) * g_test_rand_int_range (1, 40); + } + while (width * height >= 1024 * 1024); -/* larger than the small max-texture-size we test against */ -static void -test_download_1065x17 (gconstpointer data) -{ - test_download (data, 1065, 17); + test_download (data, width, height); } static void @@ -1285,9 +1277,9 @@ test_conversion_1x1 (gconstpointer data) } static void -test_conversion_4x4 (gconstpointer data) +test_conversion_random (gconstpointer data) { - test_conversion (data, 4); + test_conversion (data, g_test_rand_int_range (2, 18)); } static void @@ -1346,12 +1338,9 @@ main (int argc, char *argv[]) gtk_test_init (&argc, &argv, NULL); add_test ("/memorytexture/download_1x1", test_download_1x1); - add_test ("/memorytexture/download_4x4", test_download_4x4); - add_test ("/memorytexture/download_17x7", test_download_17x7); - add_test ("/memorytexture/download_192x192", test_download_192x192); - add_test ("/memorytexture/download_1065x17", test_download_1065x17); + add_test ("/memorytexture/download_random", test_download_random); add_conversion_test ("/memorytexture/conversion_1x1", test_conversion_1x1); - add_conversion_test ("/memorytexture/conversion_4x4", test_conversion_4x4); + add_conversion_test ("/memorytexture/conversion_random", test_conversion_random); gl_context = gdk_display_create_gl_context (gdk_display_get_default (), NULL); if (!gdk_gl_context_realize (gl_context, NULL)) -- 2.30.2